<?php



namespace App\Services\Company\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class CompanyBalanceWithdrawOrder extends Model
{
    use SoftDeletes, HasFactory;

    const STATUS_DEFAULT = 0;
    const STATUS_SUCCESS = 1;
    const STATUS_FAILURE = 2;

    protected $table = 'shop_withdraw_orders';

    protected $fillable = [
        'company_id', 'total', 'before_balance', 'status','account_id','remark'
    ];

    protected $appends = [
        'status_text',
    ];

    public function account()
    {
        return $this->belongsTo(CompanyAccount::class, 'account_id');
    }
    public function getStatusTextAttribute()
    {
        return $this->statusMapText()[$this->status] ?? '';
    }

    public function statusMapText()
    {
        return [
            self::STATUS_DEFAULT => __('已提交'),
            self::STATUS_SUCCESS => __('成功'),
            self::STATUS_FAILURE => __('失败'),
        ];
    }
}
